package com.zhss.eshop.wms.service.handler;

import com.zhss.eshop.wms.constant.PurchaseInputOrderStatus;
import com.zhss.eshop.wms.domain.dto.WmsPurchaseInputOrderDTO;
import com.zhss.eshop.wms.domain.model.WmsPurchaseInputOrder;
import com.zhss.eshop.wms.mapper.WmsPurchaseInputOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 1`更新采购入库单状态的handler
 * @author suyuan
 *
 */
@Component
public class UpdatePurchaseInputOrderStatusHandler extends AbstractPurchaseInputOrderHandler {

	/**
	 * 采购入库单管理DAO组件
	 */
	@Autowired
	private WmsPurchaseInputOrderMapper purchaseInputOrderDAO;

	/**
	 * 执行处理逻辑
	 * @param purchaseInputOrder 采购入库单
	 * @return 处理结果
	 * @throws Exception
	 */
	@Override
	public PurchaseInputOrderHandlerResult doExecute(
			WmsPurchaseInputOrderDTO purchaseInputOrder) throws Exception {
//		purchaseInputOrderDAO.updateStatus(purchaseInputOrder.getId(),
//				PurchaseInputOrderStatus.FINISH_INPUT);
		WmsPurchaseInputOrder wmsPurchaseInputOrder = purchaseInputOrderDAO.selectByPrimaryKey(purchaseInputOrder.getId());
		wmsPurchaseInputOrder.setStatus(PurchaseInputOrderStatus.FINISH_INPUT);
		purchaseInputOrderDAO.updateByPrimaryKeySelective(wmsPurchaseInputOrder);
		return new PurchaseInputOrderHandlerResult(true);
	}

}
